package com.leetcode.LC;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class LC575 {
    public int distributeCandies(int[] candyType) {

        List<Integer> list = new ArrayList<>();
        for (int i : candyType) {
            if (!list.contains(i)){
                list.add(i);
                if (list.size()>=(candyType.length/2)){
                    return candyType.length/2;
                }
            }
        }
        return list.size();
    }
    public int distributeCandies2(int[] candyType) {
        Set<Integer> set = new HashSet<Integer>();
        for (int i : candyType) {
            set.add(i);
        }

        return set.size() <= candyType.length / 2 ? set.size() : candyType.length / 2;
    }

    public static void main(String[] args) {
        System.out.println(new LC575().distributeCandies(new int[]{1, 1, 2, 2, 3, 3}));
    }
}
